function frmBegin78() {
    win78.onshow = function() {
        win78.say('Nuevo');
    }
}

if (typeof mngEstructura == 'undefined') var mngEstructura = new MngEstructura();
function newColor() {
    win78.clearForm();

    win78.loaProgram('Procesando ..');
    mngEstructura.getLastID("Color");
    mngEstructura.onresponse = function() {
        get('txtColorID').value = this.response;
        win78.stopLoading('Nuevo');
    }
}

function saveColor() {
    var txtID = get('txtColorID');
    var txtDesc  = get('txtColor');

    var id = parseInt(txtID.value, 10);
    var desc = txtDesc.value;

    if (!id || !desc) win78.say('Todos los campos son obligatorios', 'error');
    else {
        win78.loaProgram('Guardando ...');

        gMethods.groupMethods();
            mngEstructura.saveEstructura(id, 'Color', desc);
            mngEstructura.getTable('Color');
        gMethods.execMethods();
		gMethods.onresponse = function() {
            if (this.response.saveEstructura) {
                txtID.value = this.response.saveEstructura;

                fillTable('tblColors', this.response.getTable);
                win78.stopLoading('Se ha guardado correctamente la Color');
                txtDesc.value = '';
                txtDesc.focus();
            }	else win78.stopLoading('No se ha conseguido guardar la Color', 'error');
        };
    }
}

function editColor(lnk) {
    var tds = lnk.parentNode.parentNode.cells;

    get('txtColorID').value = tds[0].innerHTML;
    get('txtColor').value = tds[1].innerHTML;

    win78.say('Modificando');
    get('txtColor').focus();
}

function delColor(lnk) {
    cConfirm.onOK = function() {
        var tr = lnk.parentNode.parentNode;
        var id = parseInt(tr.cells[0].innerHTML, 10);

		win78.loaProgram('Eliminando ...');

		mngEstructura.deleteEstructura(id, 'Color');
		mngEstructura.onresponse = function() {
			if (this.response) {
				removeElement(tr);
				fillTable('tblColors');

				win78.stopLoading('Se ha eliminado correctamente la Color');
			}   else win78.stopLoading('No se ha conseguido eliminar la Color', 'error');
		};
	};
	cConfirm.show('Confirma que desea eliminar este perfil?');
}

function printColor() {
    win78.showReport('estructura', 'Colores', 'colors.pdf', 'tipo=Color');
}